Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exhaustive divrem tests for ZZ #1919

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lgoettgens
Copy link
Collaborator

Before I touch the implementations, I wanted to make sure to capture the current behavior.

Assumption: Base.divrem(x,y) == (Base.div(x,y), Base.rem(x,y) and Nemo.divrem(x,y) == (Nemo.div(x,y), Base.mod(x,y))

The few commented out tests are due to some weirdness with finite precision Ints together with unsiged Ints. All of the offending methods are in AA, and even in julia base are some discussions about what the return type of these should be.

One method I had to remove (there is a fallback via UInt -> ZZRingElem), because it did not satisfy the above assumption.

Does this look sensible?

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.21%. Comparing base (633112d) to head (26fd198).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1919      +/-   ##
==========================================
- Coverage   87.24%   87.21%   -0.03%     
==========================================
  Files          97       97              
  Lines       35590    35588       -2     
==========================================
- Hits        31049    31037      -12     
- Misses       4541     4551      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@joschmitt joschmitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think questions about such fundamental conventions are above my pay grade, sorry!

@fieker
Copy link
Contributor

fieker commented Oct 24, 2024 via email

@fieker
Copy link
Contributor

fieker commented Oct 24, 2024

... Maybe rename Nemo.divrem into divmod?

@@ -491,10 +491,6 @@ function rem(x::ZZRingElem, c::ZZRingElem)
return r
end

function rem(a::ZZRingElem, b::UInt)
return ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), a, b)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as this will remove ZZ(3) % UInt(2) I don't like it. Rather do an error if the input is illegal (ie. the remainder negative)

@lgoettgens lgoettgens marked this pull request as draft October 25, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants